<?php 
	if ((!defined("ADMIN-AREA")) || (!in_array(SHOWVIEW,$_SESSION['access']))) {
		die("No data");
	} else {
		unset($_SESSION['access']);
	}

	include "modul/funct_stat.php"; 

	if (ACT=="edit") {
		$kode = strip_tags($_GET['kode']);
		$sql1 = "SELECT * FROM tbl_hakakses WHERE tipe='".$kode."' LIMIT 1";
		$qry1 = mysql_query($sql1);
		while ($row1 = mysql_fetch_object($qry1)) {
			$typeAkses = $row1->tipe;
			$aliasAkses = $row1->alias;
			$keterangan = $row1->keterangan;
			$aktivasi = $row1->aktivasi;
		};
		$disabled = "readonly";
		$form_stat = "Edit";
	} else {
		$form_stat = "Input";
	}

	if ((ACT=="tambah") || (ACT=="edit")) {
?> 
<form name="form1" method="post" action="<?php echo $path; ?>ver_hakakses.php?show=<?php echo SHOW; ?>&showview=<?php echo SHOWVIEW; ?>">
  <table width="500" border="0" align="center" cellpadding="4" cellspacing="0">
    <tr valign="top">
      <th valign="top"><div align="left">
        <table border="0" cellpadding="4" cellspacing="2">
        <tr valign="top">
          <th valign="middle" nowrap="nowrap"> <div align="right"><?php echo $ACCESS_TITLE; ?></div></th>
          <td valign="middle"><div align="center">:</div></td>
          <td valign="middle"><div align="left">
            <input name="hakakses" type="text" id="hakakses" size="25" maxlength="25" value="<?php echo $typeAkses; ?>" <?php echo $disabled; ?> class="input-title" />
          </div></td>
        </tr>
        <tr valign="top">
          <th valign="top" colspan="3"><div align="left"><?php echo $ACCESS_TIPS_TITLE; ?></div></td>
        </tr>
        <tr valign="top">
          <th valign="top" nowrap="nowrap"> <div align="right"><?php echo $ACCESS_ALIAS; ?></div></th>
          <td valign="top"><div align="center">:</div></td>
          <td valign="top"><div align="left">
            <input name="aliasAkses" type="text" id="aliasAkses" size="30" maxlength="150" value="<?php echo $aliasAkses; ?>" />
          </div></td>
        </tr>
        <tr valign="top">
          <th valign="top" nowrap="nowrap"> <div align="right"><?php echo $ACCESS_STATUS; ?></div></th>
          <td valign="top"><div align="center">:</div></td>
          <td valign="top"><div align="left">
            <?php if ($aktivasi==1) { 
		  		$data1 = "checked";
			} else {
				$data2 = "checked";
			}
		  ?>
            <input type="radio" name="aktivasi" value="1" <?php echo $data1; ?> /><?php echo $DEV_YES; ?>
            <input type="radio" name="aktivasi" value="0" <?php echo $data2; ?> /><?php echo $DEV_NO; ?></div></td>
        </tr>
</table></div></th>
      <td width="36%" valign="top"><table border="0" cellpadding="4" cellspacing="2">
        <tr>
          <th colspan="2" valign="top"><div align="left"><?php echo $ACCESS_MODULE; ?></div></th>
          </tr>
        <tr>
          <td colspan="2" valign="top"><div align="left" style="display:block; border:thin solid #666; width:250px ;height:160px !important; overflow:auto; background-color:#FFF">
            <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="login">
              <?php

		$sql1 = "SELECT * FROM modul WHERE aktivasi='1' ORDER BY nama_modul ASC";
		$qry1 = mysql_query($sql1);
		while ($row1 = mysql_fetch_object($qry1)) {
			$sqlQ = "SELECT * FROM tbl_hakakses WHERE tipe='".$typeAkses."'";
			$qryQ = mysql_query($sqlQ);
			$rowQ = mysql_fetch_object($qryQ);
			$type_user = explode("[break]",$rowQ->keterangan);
?>
              <tr valign="top">
                <td width="30" height="20"><div align="center">
                  <input name="type[]" type="checkbox" id="type[]" value="<?php echo $row1->nama_modul; ?>"<?php if (in_array($row1->nama_modul,$type_user)) echo "checked"; ?> />
                </div></td>
                <td valign="middle" nowrap="nowrap"><div align="left"><?php echo $row1->nama_modul; ?></div></td>
                </tr>
              <?php
		}		
?>
              </table>
            </div></td>
          </tr>
      </table></td>
    </tr>
    <tr valign="top"> 
      <th colspan="2"> <div align="center">
        <input type="submit" name="submit" id="submit" value="<?php echo $DEV_CTRL_SUBMIT; ?>" />
          <input type="reset" name="Reset" value="<?php echo $DEV_CTRL_RESET; ?>" />
        <input name="kode" type="hidden" id="kode" value="<?php echo $kode; ?>">
        <input name="status" type="hidden" id="status" value="<?php echo ACT; ?>">
      </div></th>
    </tr>
  </table>
</form>
<?php
	} else {
		echo $queryData->cari_form($ACCESS_SEARCH);
		$caridata = $queryData->cari_padaku("tipe","alias");
		if (isset($_SESSION['isroot'])) {
			$sql1 = "SELECT * FROM tbl_hakakses WHERE tipe!='root' ".$caridata." ORDER BY tipe DESC LIMIT ".$limitdown.",10";
		} else {
			$sql1 = "SELECT * FROM tbl_hakakses WHERE tipe!='root'".$caridata." ORDER BY tipe DESC LIMIT ".$limitdown.",10";
		}
?>
<table border="0" align="center" cellpadding="4" cellspacing="2" class="imagesSUB">
  <tr> 
    <th width="150" height="30" class="imagesSUB"> <div align="center"><?php echo $ACCESS_TITLE; ?></div></th>
    <th width="125" class="imagesSUB"><div align="center"><?php echo $ACCESS_ALIAS; ?></div></th>
    <th width="200" class="imagesSUB"> <div align="center"><?php echo $ACCESS_MODULE; ?></div></th>
    <th width="100" class="imagesSUB"><div align="center"><?php echo $ACCESS_STATUS; ?></div></th>
	<th width="50" class="imagesSUB"><div align="center"><?php echo $DEV_ACTION; ?></div></th>
  </tr>
  <?php
		$qry1 = mysql_query($sql1);
		$numrow = mysql_num_rows($qry1);
		$num = 1;
		$x = 1;
		if ($numrow==0) {
			echo '<tr><th colspan="6">'.$DEV_NO_DATA.'</th></tr>';
		} else {
			while ($row1 = mysql_fetch_object($qry1)) {
				$data = $x % 2;
				if ($data==0) {
					$dataX = "ganjil";
				} else {
					$dataX = "genap";
				} 
				
			$keterangan = explode("[break]",$row1->keterangan);
			$keteranganX = "";
			foreach($keterangan as $arrKeterangan) {
				if ($arrKeterangan!="")
					$keteranganX .= $arrKeterangan." ";
			}
			
			if (strlen($keteranganX)>30)
				$keteranganX = substr($keteranganX,0,30)." (...)";
?>
  <tr valign="top" class="<?php echo $dataX; ?>" onmouseover="setBG('bg<?php echo $x; ?>','#FFFFDD')" onmouseout="setBG('bg<?php echo $x; ?>','')" id="bg<?php echo $x; ?>"> 
    <td><div align="left"><?php echo $row1->tipe; ?></div></td>
    <td><div align="left"><?php echo $row1->alias; ?></div>
    <div align="left"></div></td>
    <td> <div align="left"><?php echo $keteranganX; ?></div></td>
    <td><div align="center"><?php 
	if (($row1->aktivasi)=="1") {
		echo "<img src=\"".$dev_path."images/ico_check.gif\" width=\"16\" height=\"16\"></div></td>";
	} else {
		echo "<img src=\"".$dev_path."images/ico_delete.gif\" width=\"16\" height=\"16\"></div></td>";
	} ?></div></td>
<?php
	echo $queryData->ctrl_data('','index.php?show='.SHOW.'&showview='.SHOWVIEW.'&act=edit&kode='.$row1->tipe,$path.'ver_hakakses.php?show='.SHOW.'&amp;showview='.SHOWVIEW.'&amp;kode='.$row1->tipe.'&amp;act_ver=Hapus'); ?></tr>
  <?php 
		$num++;
		$x++;
	}
}
?>
</table>
<div align="center"><?php echo $queryData->next_prev($num,$pages_syarat,$limitdown); ?></div>
<?php
	}
?>
